import { gql, QueryResult, useLazyQuery } from "@apollo/client";

import { getContent } from "~/plugins/api-server";

// 查询分析任务列表
export const useSystemConfig = () => {
  const document = gql`
    query dictionarySetting($keys: [String!]!) {
      dictionarySetting(keys: $keys) {
        id
        attribute {
          value
        }
      }
    }
  `;
  const query = {
    client: getContent().dic_apiServer,
  };
  const [load] = useLazyQuery<QueryResult<any>>(document, query);
  return { load };
};

// 更新任务配置
export const updateSystemDocument = gql`
  mutation updateSetting($input: UpdateSettingInput!) {
    updateSetting(input: $input) {
      data {
        id
        item
        content {
          data
        }
        created_at
        updated_at
      }
    }
  }
`;
